
const {ccclass, property} = cc._decorator;

@ccclass
export default class RightCtrl extends cc.Component {
    private moved = false;
    public lastPos:number = 0;
    public curPos:number = 0;

    start () {
        this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
    };
    onTouchStart(e:{touch:cc.Touch}) {
    };
    onTouchMove(e:{touch:cc.Touch}) {
        this.curPos = e.touch.getLocationX();
        if (!this.moved) {
            this.lastPos = this.curPos;
            this.moved = true;
        }
    };
    onTouchEnd(e:{touch:cc.Touch}) {
        this.moved = false;
    };
}
